home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Info 1994 March
/
Internet Info CD-ROM (Walnut Creek) (March 1994).iso
/
networking
/
ip
/
ka9q
/
src.arc
/
ARPDUMP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-08-12
|
1KB
|
59 lines
#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "timer.h"
#include "arp.h"
#include "netuser.h"
void
arp_dump(bpp)
struct mbuf **bpp;
{
struct arp arp;
struct arp_type *at;
int is_ip = 0;
if(bpp == NULLBUFP || *bpp == NULLBUF)
return;
printf("ARP: len %d",len_mbuf(*bpp));
if(ntoharp(&arp,bpp) == -1){
printf(" bad packet\n");
return;
}
if(arp.hardware < NHWTYPES)
at = &Arp_type[arp.hardware];
else
at = NULLATYPE;
/* Print hardware type in Ascii if known, numerically if not */
printf(" hwtype %s",smsg(Arptypes,NHWTYPES,arp.hardware));
/* Print hardware length only if unknown type, or if it doesn't match
* the length in the known types table
*/
if(at == NULLATYPE || arp.hwalen != at->hwalen)
printf(" hwlen %u",arp.hwalen);
/* Check for most common case -- upper level protocol is IP */
if(at != NULLATYPE && arp.protocol == at->iptype){
printf(" prot IP");
is_ip = 1;
} else {
printf(" prot 0x%x prlen %u",arp.protocol,arp.pralen);
}
switch(arp.opcode){
case ARP_REQUEST:
printf(" op REQUEST");
break;
case ARP_REPLY:
printf(" op REPLY");
break;
default:
printf(" op %u",arp.opcode);
break;
}
if(is_ip)
printf(" target %s",inet_ntoa(arp.tprotaddr));
printf("\n");
}